#ifndef MAINWINDOW_H_D2
#define MAINWINDOW_H_D2

#include <QMainWindow>
#include <QTcpServer>
#include <QTcpSocket>
#include <QHostInfo>
#include <QCloseEvent>
#include <QComboBox>
#include <QSpinBox>
#include <QPushButton>
#include <QPlainTextEdit>
#include <QLineEdit>

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *event) override;

private slots:
    void onStartClicked();
    void onStopClicked();
    void onSendClicked();
    void newConnection();
    void socketReadData();
    void clientConnected();
    void clientDisconnected();

private:
    QString getLocalIpAddress();

private:
    QTcpServer *tcpServer;
    QTcpSocket *tcpSocket;

    QComboBox *comboBoxIp;
    QSpinBox *spinBoxPort;
    QPushButton *buttonStart;
    QPushButton *buttonStop;
    QLineEdit *lineEditInput;
    QPushButton *buttonSend;
    QPlainTextEdit *plainTextDisplay;
};

#endif // MAINWINDOW_H
